package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.UserScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author:hx
 * @DateTime:2022/11/16 11:25
 * @Description:
 */
@RestController
@RequestMapping("/user/schedule")
public class UserScheduleController {

    @Autowired
    private UserScheduleService userScheduleService;

    /**
     * @Description 前台分页获取排班日期信息
     * @param pageNum:
     * @param pageSize:
     * @param hoscode:
     * @param depcode:
     * @return: com.atguigu.yygh.common.result.R
     */
    @GetMapping("/{pageNum}/{pageSize}/{hoscode}/{depcode}")
    public R scheduleDatePage(@PathVariable Integer pageNum,@PathVariable Integer pageSize,@PathVariable String hoscode,@PathVariable String depcode){
        Map<String,Object> map = userScheduleService.scheduleDatePage(pageNum,pageSize,hoscode,depcode);
        return R.ok().data(map);
    }

    /**
     * @Description 前台获取医生排班信息
     * @param hoscode:
     * @param depcode:
     * @param workDate:
     * @return: com.atguigu.yygh.common.result.R
     */
    @GetMapping("/findScheduleList/{hoscode}/{depcode}/{workDate}")
    public R findScheduleList(@PathVariable String hoscode, @PathVariable String depcode, @PathVariable String workDate){
        List<Schedule> scheduleList = userScheduleService.findScheduleList(hoscode,depcode,workDate);
        return R.ok().data("scheduleList",scheduleList);
    }

    /**
     * @Description 根据id获取排班信息
     * @param id:
     * @return: com.atguigu.yygh.common.result.R
     */
    @GetMapping("/getSchedule/{id}")
    public R getSchedule(@PathVariable String id){
        Schedule schedule = userScheduleService.getSchedule(id);
        return R.ok().data("schedule",schedule);
    }

    /**
     * @Description 用与订单获取医院排班信息
     * @param hosScheduleId:
     * @return: com.atguigu.yygh.vo.hosp.ScheduleOrderVo
     */
    @GetMapping("/getScheduleOrder/{hosScheduleId}")
    public ScheduleOrderVo getScheduleOrder(@PathVariable String hosScheduleId) {
        return userScheduleService.getScheduleOrder(hosScheduleId);
    }
}
